home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / xview / genial / lib / backup / atest.c next >
Encoding:
C/C++ Source or Header  |  1992-07-14  |  1.8 KB  |  95 lines

  1.  
  2. #include <stdio.h>
  3. #include <sys/types.h>
  4. #include <hipl_format.h>
  5.  
  6. char     *Progname;
  7.  
  8. u_char ***image;
  9.  
  10. /* input image info */
  11. int       rw, cl, nf;        /* number of rows, columns in the image */
  12. int       pix_format;
  13.  
  14.  
  15. /*****************************************************/
  16. main(argc, argv)
  17.     int       argc;
  18.     char    **argv;
  19. {
  20.     register int c, r, f, idx;
  21.  
  22.     struct header hd;        /* hips header */
  23.  
  24.     u_char ***alloc_3d_byte_array(), *image_ptr;
  25.  
  26.     Progname = strsave(*argv);
  27.  
  28.     read_header(&hd);
  29.     if (hd.pixel_format != PFBYTE)
  30.     perr("image must be in byte format");
  31.  
  32.     rw = hd.rows;        /* y axis */
  33.     cl = hd.cols;        /* x axis */
  34.     nf = hd.num_frame;
  35.     pix_format = hd.pixel_format;
  36.  
  37.     fprintf(stderr, "\n rows: %d,  cols: %d,  frames: %d \n", rw, cl, nf);
  38.  
  39.     image = alloc_3d_byte_array(nf, rw, cl);
  40.  
  41.  
  42.     fprintf(stderr, "\n loading image... \n ");
  43.  
  44.     read_3d_byte_array(stdin, image, nf, rw, cl);
  45.  
  46.  
  47. #ifdef DEBUG
  48.     show_slice(fr);
  49. #endif
  50.  
  51.         image_ptr = **image;
  52.     idx = 0;
  53.  
  54.     for (f = 0; f < nf; f++) {
  55.         fprintf(stderr, " frame %d ", f);
  56.         for (r = 0; r < rw; r++)
  57.         for (c = 0; c < cl; c++) {
  58. /* works
  59.             if (image[f][r][c] != (*((**image)+idx)))
  60. */
  61. /* works 
  62.             if (image[f][r][c] != (**image)[idx++])
  63. */
  64.  
  65. /* also works
  66.             if (image[f][r][c] != *((**image)++))
  67. */
  68. /* fastest method */
  69.             if (image[f][r][c] != *(image_ptr++))
  70.             fprintf(stderr, " val 1: %d, val 2: %d \n",
  71.                 image[f][r][c], (**image)[idx-1]);
  72.         }
  73.     }
  74.  
  75.     fprintf(stderr, "\n\n finished. \n\n");
  76.     return (0);
  77. }
  78.  
  79.  
  80. /***************************************************************/
  81.  
  82. show_slice(sn)            /* for debugging  */
  83.     int       sn;
  84. {
  85.     register int c, r;
  86.  
  87.     fprintf(stderr, "\n frame #: %d \n", sn);
  88.  
  89.     for (r = 0; r < rw; r++) {
  90.     for (c = 0; c < cl; c++)
  91.         fprintf(stderr, "%3d", image[r][c]);
  92.     fprintf(stderr, "\n");
  93.     }
  94. }
  95.